﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AAA.Schedule
{
    public abstract class AbstractTask : ITask
    {
        private string _strTaskName;
        private TaskStatusEnum _eTaskStatus;
        private TaskTypeEnum _eTaskType;
        private DateTime _dtStartTime;
        private DateTime _dtEndTime;
        private DateTime _dtNextExecuteTime;
        private DateTime _dtCompletedTime;
        private long _lInterval;
        private bool _IsExecuteAtStart;
        #region ITask Members

        public string TaskName
        {
            get
            {
                return _strTaskName;
            }
            set
            {
                _strTaskName = value;
            }
        }

        public TaskStatusEnum TaskStatus
        {
            get { return _eTaskStatus; }
            set { _eTaskStatus = value; }
        }

        public TaskTypeEnum TaskType
        {
            get
            {
                return _eTaskType;
            }
            set
            {
                _eTaskType= value;
            }
        }

        public DateTime StartTime
        {
            get
            {
                return _dtStartTime;
            }
            set
            {
                _dtStartTime = value;
                _dtNextExecuteTime = value;
                _dtCompletedTime = DateTime.MinValue;
            }
        }

        public DateTime EndTime
        {
            get
            {
                return _dtEndTime;
            }
            set
            {
                _dtEndTime = value;
            }
        }

        public long Interval
        {
            get
            {
                return _lInterval;
            }
            set
            {
                _lInterval = value;
            }
        }

        public DateTime NextExecuteTime
        {
            get
            {
                return _dtNextExecuteTime;
            }
            set
            {
                _dtNextExecuteTime = value;
            }
        }

        public DateTime CompletedTime
        {
            get { return _dtCompletedTime; }
            set { _dtCompletedTime = value; }
        }

        public bool ExecuteAtStart
        {
            get
            {
                return _IsExecuteAtStart;
            }
            set
            {
                _IsExecuteAtStart = value;
            }
        }

        public abstract IExecuteResult Execute(Dictionary<string, object> dicData);

        #endregion
    }
}
